package modele;

import java.sql.SQLException;
import java.util.Collection;
import java.util.HashSet;
import java.util.TreeSet;

public class Pays {
    private Collection<Dep> lesDeps;
    private Collection<Spe> lesSpes;
    
    public Pays() {
        DAO.charge(this);
    }
    public void setLesDeps(Collection<Dep> c) {
        lesDeps = c;
    }
    public void setLesSpes(Collection<Spe> c) {
        lesSpes = c;
    }
    public Collection<Dep> getLesDeps() {
        return lesDeps;
    }
    public Collection<Spe> getLesSpes() {
        return lesSpes;
    }
    public Dep getLeDep(String numDep) {
        for(Dep d : lesDeps) {
            if(d.getNum().equals(numDep)) {
                return d;
            }
        }
        return null;
    }
    public Spe getLaSpe(String spe) {
        for(Spe s : lesSpes) {
            if(s.getLibelle().equals(spe)) {
                return s;
            }
        }
        return null;
    }
    public Collection<Med> getMedNom(String n) {
        Collection<Med> medn = new TreeSet<Med>();
        Collection<Dep> deps = this.getLesDeps();
        for(Dep dep : deps) {
            Collection <Med> meds = dep.getLesMeds();
            for(Med med : meds) {
                if(med.getNom().startsWith(n)) {
                    medn.add(med);
                }
            }
        }
        return medn;
    }
}
